#include <iostream>
#include <string>
using namespace std;
class Solution {
public:
    string reverseStr(string s, int k) {
		int i = 0;
        while(i<s.size())
        {
			if (i + k < s.size())
				reverse(s.begin() + i, s.begin() + i + k);
			else
				reverse(s.begin() + i, s.end());
			i += 2 * k;
        }
		return s;
    }
};
int main()
{
	Solution sol;
	cout << sol.reverseStr("abcsaw", 2) << endl;
}